const BASE_URL = 'http://124.220.177.66:8082'
const json2url = (data) => { //{a:1,b:2}
	let arr = [];
	for (let name in data) { //name 变量代表  遍历过程中每一个键
		arr.push(name + '=' + data[name]); //['a=1','b=2']
	}
	return arr.join('&')
}
const http = ({
	url,
	params = {},
	data = {},
	method = 'get'
}) => {
	if (!url) return;
	// const token=wx.getStorageSync('token') || ''
	return new Promise((resolve, reject) => {
		uni.request({
			url: BASE_URL + url + '?' + json2url(params),
			method: method,
			// header: {
			// 	token
			// },
			data: data,
			success: function(res) {
				resolve(res);
			},
			fail: function(err) {
				reject(err);
			}
		})
	})
}
export default {
	http,
	BASE_URL
}
